<template>
	<view style="border: 1px solid;">
		<up-form labelPosition="left" :labelStyle="labelStyle" :borderBottom="true" class="apply-form-field"
			:model="data" ref="needFhDateRef" :rules="rules">
			<!-- #ifdef APP-->
			<up-form-item :borderBottom="true" label-width="140" label="要求发货时间" required @tap="dateClick()"
				prop="needFhDate">
				<up-input v-model="data.needFhDate" placeholder="请选择时间" readonly></up-input>
			</up-form-item>
			<!-- #endif -->
			<!-- #ifdef H5-->
			<up-form-item :borderBottom="true" label-width="140" label="要求发货时间" required prop="needFhDate">
				<up-input v-model="data.needFhDate" placeholder="请选择时间" @click.native="dateShow=true" @focus='blur'></up-input>
			</up-form-item>
			<!-- #endif -->
		</up-form>
		<up-loadmore loadmoreText="请在下方对销售子单进行拆单" color="red" lineColor="red" line />
		<u-line color="#00aa00" dashed></u-line>
		<up-tabs :list="titleList" lineWidth="60" @click="click" :current="currentTab" :activeStyle="{
					            color: '#55aa00',
					            fontWeight: 'bold',
					            transform: 'scale(1.05)'
					        }" :inactiveStyle="{
					            color: '#606266',
					            transform: 'scale(1)'
					        }" itemStyle="padding-left: 15px; padding-right: 15px; height: 44px;">
			<template #right>
				<view style="padding-left: 4px;">
					<up-icon name="plus-circle-fill" size="27" bold color="red" @tap="addOrderSub"></up-icon>
				</view>
			</template>
		</up-tabs>
		<u-line color="#00aa00" dashed></u-line>
		<up-back-top :scroll-top="scrollTop" top="300" mode="circle" bottom="350rpx"
			:iconStyle="{'fontSize': '32rpx','color': '#ffffff'}" :customStyle="{'backgroundColor': 'green'}"
			class="kkasd"></up-back-top>
		<swiper :indicator-dots="false" class="swiper1" :style="{'backgroundColor':'white','height':(1700+100*belongList.length)+'rpx'}" :current="current"
			@change='changeSwiper'>
			<swiper-item v-for="(item,index) in indentList" :key="index">
				<up-form labelPosition="left" :labelStyle="labelStyle" :borderBottom="true" class="apply-form-field"
					:model="item" :ref="'orderForm'+index" :rules="purchaseRules">
					<up-form-item label="销售子单" label-width="140" prop="skuName" :borderBottom="true" required>
						<up-radio-group v-model="item.belongId" shape="square" @change="orderChange">
							<up-radio v-for="(item, index) in sourceTitleList" :key="index" :name="item.id"
								:label="item.name" :customStyle="{marginRight: '0px'}" activeColor="green">
							</up-radio>
						</up-radio-group>
					</up-form-item>
					<up-form-item label="SKU名称" label-width="140" prop="skuName" :borderBottom="true" required>
						<!-- 						<div style="height: 40rpx;text-align: center;">
							{{item.skuName}}
						</div> -->
						<up-input type="text" class="form-field-select" v-model="item.skuName" readonly
							placeholder="选择待拆单的销售子单" />
					</up-form-item>
					<up-form-item label="外包装" label-width="140" prop="packageMethod" :borderBottom="true" required>
						<up-input type="text" class="form-field-select" v-model="item.packageMethod" readonly
							placeholder="选择待拆单的销售子单" />
					</up-form-item>
					<up-form-item label="内包装" label-width="140" prop="innerPackageMethod" :borderBottom="true">
						<up-input type="text" class="form-field-select" v-model="item.innerPackageMethod" readonly
							:placeholder="item.belongId == null ? '选择待拆单的销售子单':'无'" />
					</up-form-item>
					<up-form-item label="产品" label-width="140" prop="productName" :borderBottom="true" required>
						<up-input type="text" class="form-field-select" v-model="item.productName" readonly
							placeholder="选择待拆单的销售子单" />
					</up-form-item>
					<up-form-item label="品种" label-width="140" prop="varietySplits" :borderBottom="true" required>
						<up-input border="none" readonly v-if="item.varietySplits">
							<template #prefix>
								<template v-for="(item1, index) in item.varietySplits" :key="index">
									{{ item1+"、" }}
								</template>
							</template>
						</up-input>
						<up-input border="none" readonly placeholder="选择待拆单的销售子单" v-else></up-input>
					</up-form-item>
					<up-form-item label="等级" label-width="140" prop="grade" :borderBottom="true" required>
						<up-input type="text" class="form-field-select" v-model="item.grade" readonly
							placeholder="选择待拆单的销售子单" />
					</up-form-item>
					<!-- #ifdef APP-->
					<up-form-item label="园区名称" label-width="140" prop="companyName" :borderBottom="true"
						@tap="parkShowClick" required>
						<up-input placeholder="请选择分配园区" type="text" class="form-field-select"
							v-model="item.companyName" border="none" readonly />
					</up-form-item>
					<!-- #endif -->
					<!-- #ifdef H5-->
					<up-form-item label="园区名称" label-width="140" prop="companyName" :borderBottom="true" required>
						<up-input placeholder="请选择分配园区" type="text" class="form-field-select"
							v-model="item.companyName" border="none" @click.native="parkShow=true" @focus='blur' />
					</up-form-item>
					<!-- #endif -->
					<!-- 					<up-form-item label="园区名称" label-width="140" prop="yq_full_name" :borderBottom="true" required>
						<up-input type="text" class="form-field-select" v-model="item.yq_full_name" readonly />
					</up-form-item> -->
					<up-form-item label="最小规格/kg" label-width="140" prop="minimum" :borderBottom="true" required>
						<up-input type="number" class="form-field-select" v-model="item.minimum"
							@update:modelValue="getOrderTotal(item)" placeholder="请输入最小规格/kg" />
					</up-form-item>
					<up-form-item label="箱规(数量)" label-width="140" prop="weight" :borderBottom="true" required>
						<up-input type="number" class="form-field-select" v-model="item.weight"
							@update:modelValue="getOrderTotal(item)" placeholder="请输入箱规(数量)" />
					</up-form-item>
					<up-form-item label="订货数量(箱/件)" label-width="140" prop="piece" :borderBottom="true" required>
						<up-input type="number" class="form-field-select" v-model="item.piece"
							@update:modelValue="getOrderTotal(item)" placeholder="请输入订货数量(箱/件)" />
					</up-form-item>
					<up-form-item label="订单重量" label-width="140" prop="weightTotal" :borderBottom="true" required>
						<up-input type="number" class="form-field-select" v-model="item.weightTotal" readonly
							@update:modelValue="getOrderTotal(item)" placeholder="自动计算" />
					</up-form-item>
					<up-form-item label="采购单价/元" label-width="140" prop="orderPrice" :borderBottom="true" required>
						<up-input type="number" class="form-field-select" v-model="item.orderPrice"
							@click.native="getOrderPrice(item,currentTab)" @update:modelValue="getOrderTotal(item)"
							placeholder="点击获取" />
					</up-form-item>
					<up-form-item label="采购总金额/元" label-width="140" prop="buyPriceTotal" :borderBottom="true" required>
						<up-input type="number" class="form-field-select" v-model="item.buyPriceTotal" readonly
							@update:modelValue="getOrderTotal(item)" placeholder="自动计算" />
					</up-form-item>

					<up-form-item label="出库类型" label-width="140" prop="type" required :borderBottom="true">
						<up-radio-group v-model="item.type" shape="square">
							<up-radio v-for="(item, index) in typeList" :key="item" :name="item" :label="item"
								activeColor="green"></up-radio>
						</up-radio-group>
					</up-form-item>
					<up-form-item label="是否分级" label-width="140" prop="isGraded" required :borderBottom="true">
						<up-radio-group v-model="item.isGraded" shape="square">
							<up-radio v-for="(item, index) in gradedList" :key="item" :name="item" :label="item"
								activeColor="green"></up-radio>
						</up-radio-group>
					</up-form-item>
					<up-form-item label="是否标重" label-width="140" prop="isStandardWeight" required :borderBottom="true">
						<up-radio-group v-model="item.isStandardWeight" shape="square">
							<up-radio v-for="(item, index) in standardWeightList" :key="item" :name="item" :label="item"
								activeColor="green"></up-radio>
						</up-radio-group>
					</up-form-item>
					<!-- 					<up-form-item label="关联订单" label-width="140" prop="relatedList" :borderBottom="true" required>
						<up-input type="text" class="form-field-select" v-model="item.relatedList"
							placeholder="请选择关联订单" />
					</up-form-item> -->
					<!-- #ifdef APP-->
					<up-form-item label="关联订单" label-width="110" prop="relatedString" :borderBottom="true"
						@tap="orderNumClick">
						<up-input placeholder="请选择关联订单" type="text" class="form-field-select"
							v-model="item.relatedString" border="none" readonly />
					</up-form-item>
					<!-- #endif -->
					<!-- #ifdef H5-->
					<up-form-item label="关联订单" label-width="110" prop="relatedString" :borderBottom="true">
						<u-textarea placeholder="请选择关联订单" type="text" class="form-field-select" height="50"
							@click.native="orderNumShow=true" v-model="item.relatedString" border="none"
							@focus='blur' />
					</up-form-item>
					<!-- #endif -->
					<up-form-item label="新旧货" label-width="140" prop="extent" required :borderBottom="true">
						<up-radio-group v-model="item.extent" shape="square">
							<up-radio v-for="(item, index) in extentList" :key="index" :name="item" :label="item"
								activeColor="green"></up-radio>
						</up-radio-group>
					</up-form-item>
					<up-form-item label="打托方式(箱/托)" label-width="140" prop="palletizingMethod" :borderBottom="true"
						required>
						<up-input type="text" class="form-field-select" v-model="item.palletizingMethod"
							placeholder="请输入打托方式" />
					</up-form-item>
					<up-form-item label="备注" label-width="140" prop="notes" :borderBottom="true" required>
						<up-input type="text" class="form-field-select" v-model="item.notes" />
					</up-form-item>
					<view style="display: flex;margin-top:1%;margin-bottom:1%;">
						<up-button type="primary" shape="circle" size="small" hairline plain text="新增子单"
							icon="plus-circle-fill" @click="addOrderSub"
							style="margin-left: 2%;margin-right: 2%;"></up-button>
						<u-button type="primary" shape="circle" size="small" hairline plain text="复制子单" icon="file-text"
							@click="copyOrderSub(index)" style="margin-right: 2%;"></u-button>
						<up-button color="#ff0000" shape="circle" size="small" hairline plain text="删除子单" icon="trash"
							@click="delOrderSub(index)" style="margin-right: 2%;"></up-button>
					</view>
					<up-loadmore loadmoreText="可左右滑动" color="red" lineColor="red" line />
				</up-form>
			</swiper-item>
		</swiper>
		<!-- 		<view style="margin-top: 50rpx;padding: 0rpx 30% 0rpx 30%;">
			<up-button type="primary" color="green" shape="circle" text="采购下单" @click="purchaseSave"></up-button>
		</view> -->
		<!-- 指定园区 -->
		<u-picker :show="parkShow" :columns="parkList" keyName="company_name" @confirm="parkConfirm" @close="parkClose"
			@cancel="parkClose" closeOnClickOverlay></u-picker>

		<!-- 关联订单 -->
		<multiple-picker title="请选择(近一个月订单)" :show="orderNumShow" :columns="orderNumList" :defaultIndex="orderNumIndex"
			@confirm="confirmOrderNum" @cancel="orderNumShow = false" @change="changeOrderNum"></multiple-picker>

		<u-calendar :show="dateShow" mode="single" @confirm="timeConfirm" @close="dateShow=false"
			:minDate="minDate" :maxDate="maxDate" :monthNum="12"></u-calendar>
			
		<!-- 模态窗口 -->
		<u-modal :show="modalShow" :showConfirmButton='false'>
			<view class="slot-content">
				<rich-text nodes="采购下单中，请稍后......"></rich-text>
			</view>
		</u-modal>	
	</view>
</template>

<script>
	import orderApi from '@/apis/gyl/order.js';
	import {
		onPageScroll
	} from '@dcloudio/uni-app';
	import {
		ref,
		reactive
	} from 'vue';
	export default {
		props: {
			belongList: {
				type: Array,
				default: {}
			},
			date: {
				type: String,
				default: {}
			},
			info: {
				type: Object,
				default: {}
			}
		},
		data() {
			return {
				data: {
					needFhDate: null,
				},
				minDate: '2025-01-01',
				maxDate: '2035-01-01',
				dateShow: false,
				orderNumList: [],
				orderNumShow: false,
				orderNumIndex: [],
				scrollTop: 0,
				labelStyle: {
					color: '#aaa',
					fontSize: '30rpx'
				},
				current: 0,
				currentTab: 0,
				titleList: [],
				sourceTitleList: [],
				indentList: [],
				orderSubLetter: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
					'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
				],
				standardWeightList: ['标重', '非标重'],
				extentList: ['新货(库存四天内)', '旧货(库存四天以上)'],
				typeList: ['销售', '赠品', '样品'],
				gradedList: ['分级出库', '通货出库'],
				parkShow: false,
				parkList: [],
				priceList: [],
				modalShow: false,
				rules: {
					needFhDate: [{
						required: true,
						trigger: ['blur', 'change'],
						message: "请选择时间"
					}]
				},
				purchaseRules: {
					belongId: [{
						required: true,
						message: '请选择需要拆单的销售子单',
						trigger: ['blur', 'change']
					}],
					skuName: [{
						required: true,
						message: '请选择需要拆单的销售子单',
						trigger: ['blur', 'change']
					}],
					packageMethod: [{
						required: true,
						message: '请选择需要拆单的销售子单',
						trigger: ['blur', 'change']
					}],
					// innerPackageMethod: [{
					// 	required: true,
					// 	message: '请选择需要拆单的销售子单',
					// 	trigger: ['blur', 'change']
					// }],
					productName: [{
						required: true,
						message: '请选择需要拆单的销售子单',
						trigger: ['blur', 'change']
					}],
					varietyList: [{
						type: 'array',
						required: true,
						message: '请选择品种',
						trigger: ['blur', 'change']
					}],
					grade: [{
						required: true,
						message: '请选择需要拆单的销售子单',
						trigger: ['blur', 'change']
					}],
					companyName: [{
						required: true,
						message: '请选择分配园区',
						trigger: ['blur', 'change']
					}],
					minimum: [{
						required: true,
						message: '请填写最小规格',
						trigger: ['blur', 'change']
					}],
					weight: [{
						required: true,
						message: '请填写箱规',
						trigger: ['blur', 'change']
					}],
					piece: [{
						required: true,
						message: '请填写订货数量',
						trigger: ['blur', 'change']
					}],
					weightTotal: [{
						required: true,
						message: '请填写订单重量',
						trigger: ['blur', 'change']
					}],
					orderPrice: [{
						required: true,
						message: '请填写采购单价',
						trigger: ['blur', 'change']
					}],
					buyPriceTotal: [{
						required: true,
						message: '请获取采购单价',
						trigger: ['blur', 'change']
					}],
					type: [{
						required: true,
						message: '请选择出库类型',
						trigger: ['blur', 'change']
					}],
					isGraded: [{
						required: true,
						message: '请选择是否分级',
						trigger: ['blur', 'change']
					}],
					isStandardWeight: [{
						required: true,
						message: '请选择是否标重',
						trigger: ['blur', 'change']
					}],
					extent: [{
						required: true,
						message: '请选择新旧货',
						trigger: ['blur', 'change']
					}],
					palletizingMethod: [{
						required: true,
						message: '请填写打托方式',
						trigger: ['blur', 'change']
					}],
				}
			}
		},

		methods: {
			
			/**
			 * app 调用
			 */
			dateClick() {
				this.dateShow = true;
			},

			/**
			 * 签收时间
			 */
			timeConfirm(e) {
				this.data.needFhDate = e[0];
				this.dateShow = false;
			},

			/**
			 * 回到顶部
			 */
			scrollToTop() {
				uni.pageScrollTo({
					scrollTop: 0
				});
			},

			orderNumClick() {
				this.orderNumShow = true;
				// this.$refs.orderForm.validateField('customerName');				
			},

			changeSwiper(e) {
				this.current = e.detail.current;
				this.currentTab = e.detail.current;
			},

			/**
			 * 子单选择切换
			 * @param {Object} e
			 */
			orderChange(e) {
				console.info(e)
				var source = this.sourceTitleList.filter(item => item.id == e);
				this.titleList[this.currentTab].name = source[0].name;
				this.indentList[this.currentTab] = {};
				var arr = this.belongList.filter((item) =>
					item.id == e
				);
				var obj = {};
				this.getOrder(obj, arr[0]);
				this.indentList[this.currentTab] = obj;
				const ref = eval("this.$refs.orderForm" + this.currentTab)[0];
				ref.validateField('type');
				ref.validateField('isGraded');
				ref.validateField('isStandardWeight');
				ref.validateField('extent');
			},

			click(e) {
				this.currentTab = e.index;
				this.current = e.index;
			},

			parkShowClick() {
				this.parkShow = true;
				// this.$refs.orderForm.validateField('customerName');						
			},

			/**
			 * 指定园区取消
			 */
			parkClose() {
				this.parkShow = false;
			},

			/**
			 * 禁止弹出
			 */
			async blur() {
				await uni.hideKeyboard();
			},

			/**指定园区确认
			 * @param {Object} e
			 */
			parkConfirm(e) {
				console.info(e)
				this.indentList[this.currentTab].companyName = e.value[0].company_name;
				this.indentList[this.currentTab].newDbName = e.value[0].new_db_name;
				this.parkClose();
				const ref = eval("this.$refs.orderForm" + this.currentTab)[0];
				ref.validateField('companyName');

			},

			getOrder(obj, item) {
				if (item == null) {
					obj.belongId = null;
					obj.productName = null;
					obj.varietyName = null;
					obj.grade = null;
					obj.packageMethod = null;
					obj.minimum = null;
					obj.weight = null;
					obj.piece = null;
					obj.orderPrice = null;
					obj.weightTotal = null;
					obj.extent = null;
					obj.type = null;
					obj.unit = null;
					obj.innerPackageMethod = null;
					obj.palletizingMethod = null;
					obj.isStandardWeight = null;
					obj.outShouldReceiveNum = null;
					obj.innerShouldReceiveNum = null;
					obj.buyPriceTotal = null;
					obj.skuName = null;
					obj.varietySplits = null;
					obj.gradeSplits = null;
					obj.relatedList = null;
					obj.isGraded = null;
					obj.companyName = null;
					obj.newDbName = null;
					return
				}
				obj.belongId = item.id;
				obj.productName = item.productName;
				// if (item.varietyName) {
				// 	obj.varietyName = item.varietyName.split(",");
				// }
				obj.varietyName = item.varietyName;
				obj.grade = item.grade;
				obj.packageMethod = item.packageMethod;
				obj.minimum = item.minimum;
				obj.weight = item.weight;
				obj.piece = item.piece;
				obj.orderPrice = null;
				obj.weightTotal = item.weightTotal;
				obj.extent = item.extent;
				obj.type = item.type;
				obj.unit = item.unit;
				obj.innerPackageMethod = item.innerPackageMethod;
				obj.palletizingMethod = item.palletizingMethod;
				obj.isStandardWeight = item.isStandardWeight;
				obj.outShouldReceiveNum = item.outShouldReceiveNum;
				obj.innerShouldReceiveNum = item.innerShouldReceiveNum;
				obj.buyPriceTotal = "";
				obj.skuName = item.skuName;
				obj.varietySplits = item.varietySplits;
				obj.gradeSplits = item.gradeSplits;
				obj.relatedList = item.relatedList;
				obj.isGraded = item.isGraded;
				if (item.newDbName != '' && item.newDbName != null) {
					obj.companyName = item.companyName;
					obj.newDbName = item.newDbName;
				}
			},

			getOrderPrice(row, index) {
				if (row.skuName == '' || !row.skuName) {
					this.$message.error("请先选择SKU");
					return;
				}
				let newArray = this.priceList.filter(
					(item) => (item.catName === row.productName &&
						row.grade === item.grade)
				);
				let price = '0.00';
				for (let item of newArray) {
					if (!item.startDate) {
						continue;
					}
					let startDate = new Date(item.startDate);
					let endDate = new Date(item.endDate);
					let orderDate = new Date(this.date);
					if (startDate.getTime() <= orderDate.getTime() && orderDate.getTime() <= endDate.getTime()) {
						price = item.purchasePrice;
                            // 检查是否是百分比格式
                        if (typeof price === 'string' && price.includes('%')) {
                               // 提取百分比数字部分
                               let percentage = parseFloat(price) / 100;
                               // 在detailList中查找对应的销售价格
                               const saleItem = this.belongList.find(detail => 
                                  detail.id === row.belongId
                               );
                                // 确保找到了对应的销售价格
                               let salePrice = saleItem ? saleItem.desc : 0;
                               // 计算最终价格
                                price = (percentage * salePrice).toFixed(2);
                       } else {
                             // 如果不是百分比，则直接使用purchasePrice，确保其为两位小数
                               price = parseFloat(price).toFixed(2);
                       }						
					}
				}
				this.$nextTick(() => {
					this.indentList[index]['orderPrice'] = (price * 1).toString();
					row.weightTotal = (row.weight * row.piece * row.minimum).toFixed(2);
					row.buyPriceTotal = (row.weightTotal * price).toFixed(2);
					this.$forceUpdate()
				})
				this.$forceUpdate();
				const ref = eval("this.$refs.orderForm" + index)[0];
				ref.validateField('orderPrice');
				ref.validateField('buyPriceTotal');
			},

			getOrderTotal(row) {
				if (row) {
					row.weightTotal = (row.weight * row.piece * row.minimum).toFixed(2);
					if (row.grade != '' && row.grade != null) {
						row.buyPriceTotal = (row.weightTotal * row.orderPrice).toFixed(2);
					}
				} else {
					row.weightTotal = "0.00";
					row.buyPriceTotal = "0.00";
				}
				// this.changeStandardWeight(row);
			},

			addOrderSub() {
				this.titleList.push({
					name: '请选择销售子单'
				});
				var obj = {};
				this.getOrder(obj, null);
				this.indentList.push(obj);
				this.current = this.indentList.length - 1;
				this.currentTab = this.current;
				this.scrollToTop();
				this.$nextTick(() => {
					const ref = eval("this.$refs.orderForm" + (this.indentList.length - 1))[0];
					console.info(ref)
					ref.setRules(this.purchaseRules);
				})

			},

			delOrderSub(index) {
				this.titleList.splice(index, 1);
				this.indentList.splice(index, 1);
				this.current = 0;
				this.currentTab = 0;
				this.scrollToTop();
			},

			copyOrderSub(index) {
				var order = this.indentList[index];
				var obj = {};
				Object.assign(obj, order);
				console.info(obj)
				if (obj.productName) {
					this.titleList.push({
						name: this.titleList[index].name
					})
				} else {
					this.titleList.push({
						name: '请选择销售子单'
					})
				}

				this.indentList.push(obj);
				this.current = this.indentList.length - 1;
				this.currentTab = this.current;
				this.scrollToTop();
				this.$nextTick(() => {
					const ref = eval("this.$refs.orderForm" + (this.indentList.length - 1))[0];
					ref.setRules(this.purchaseRules);
				})
			},

			/**
			 * 采购下单
			 */
			async purchaseSave() {
				console.info(this.indentList)
				var flag = true;
				var index = 0;
				for (var i = 0; i < this.indentList.length; i++) {
					const ref = eval("this.$refs.orderForm" + i)[0];
					await ref.validate().then(res => {}).catch(errors => {
						flag = false;
						index = i;
						uni.$u.toast(errors[0].message)
					})
					if (!flag) {
						break;
					}
				}
				if (!flag) {
					this.current = index;
					this.currentTab = index;
					return;
				}
				await this.$refs.needFhDateRef.validate().then(res => {}).catch(errors => {
					flag = false;
					uni.$u.toast(errors[0].message)
				})
				if (!flag) {
					return;
				}
				this.modalShow = true;
				const res = await orderApi.purchaseOrder({
					info: this.info,
					indentList: this.indentList,
					needFhDate: this.data.needFhDate
				});
				if(res.success){
					this.modalShow = false;
					uni.showToast({
						icon: 'none',
						duration: 1000,
						title: '采购下单成功',
						complete:function(){
							var timer = setInterval(()=>{
								uni.navigateBack();
								clearInterval(timer);
							},1000)
						}
					});
					
				}else{
					uni.showToast({
						icon: 'none',
						duration: 1000,
						title: '采购下单失败'
					});					
				}
			},

			/**关联订单确认时触发
			 * @param {Object} e
			 */
			confirmOrderNum(e) {
				if (e.selected) {
					var arr = e.selected.map(item => item.label);
					console.info(arr)
					this.indentList[this.current].relatedString = arr.join(",");
					this.indentList[this.current].relatedList = e.selected.map(item => item.value);
				}
				this.orderNumShow = false;
			},

			/**关联订单勾选时触发
			 * @param {Object} e
			 */
			changeOrderNum(e) {
				// console.log(e);	
			},

			// ----------------------------------------------------------------------- api ----------------------------------------------------------
			/**
			 * 获取所有园区
			 */
			async getYQListPHPApi() {
				this.parkList = [];
				uni.request({
					url: 'http://103.254.76.5/index.php/User/UserInfo/get_yq_list3',
					success: res => {
						this.parkList.push(res.data.data);
					}
				})
			},

			/**
			 * 获取价格列表
			 */
			async getPriceListApi() {
				let res = await orderApi.getPriceList();
				if (res.success) {
					this.priceList = res.data;
				}
			},

			/**
			 * 关联订单
			 */
			async getRelatedOrderListApi() {
				const res = await orderApi.listRelatedOrder()
				this.orderNumList = [];
				if (res.success) {
					this.orderNumList = res.data;
				}
			},
		},
		mounted() {
			this.getYQListPHPApi();
			this.getPriceListApi();
			this.getRelatedOrderListApi();
			this.belongList.forEach((item, index) => {
				this.titleList.push({
					name: item.productName + '[' + this.orderSubLetter[index] + ']'
				});
				this.sourceTitleList.push({
					name: item.productName + '[' + this.orderSubLetter[index] + ']',
					id: item.id
				})
				if (item.relatedOrderNum) {
					this.relatedString = item.relatedOrderNum
				}
				// console.info(this.sourceTitleList)
				let obj = {};
				this.getOrder(obj, item);
				this.indentList.push(obj);
			})
		},
		setup() {
			// 使用 ref 创建响应式基本类型数据  
			const scrollTop = ref(0);
			// onPageScroll 方法来更新 scrollTop 的值  
			onPageScroll((e) => {
				scrollTop.value = e.scrollTop;
			});
			return {
				scrollTop,
				onPageScroll
			}
		}
	}
</script>

<style>
/* 	.swiper1 {
		min-height: 1930rpx;
	} */

	.u-radio {
		margin-right: 8px !important;
	}

	.u-radio-group {
		gap: 0px !important;
	}

	.u-radio-group--row {
		flex-wrap: wrap;
	}

	::v-deep .u-input {
		padding: 6px 0px !important;
	}

	.apply-form-field {
		background: #ffffff;

		.u-form-item {
			padding: 0px 15px !important;
		}

		.input-placeholder {
			text-align: left !important;
			font-size: 28rpx;
		}

		.uni-input-input {
			text-align: left !important;
		}

		.form-field-select {
			.u-iconfont {
				font-size: 0 !important;
			}
		}

		.add-user {
			color: #bfbfbf;
			font-size: 30px;
		}

		.apply-name {
			color: #333333;
			line-height: 20px;

			span {
				color: #999999;
				display: block;

			}
		}

		.apply-link {
			.u-link {
				color: #5ab149 !important;
				padding: 0 5px;
			}
		}

		.u-close--top-right {
			top: 5px !important;
		}

		.popup-title {
			color: #333333;
			padding: 5px 10px;
			font-size: 30rpx;
		}

		.u-cell {
			padding: 8px 12px !important;
		}
	}
</style>